import time

#转义字符
"""
\n \t \r  \\
"""
print("\\\\")   # >>> \\
print(r"\\\\")   # >>> \\\\  r表示不转义


user = "Mr.Li"
a1 = 10
a2 = 20
print(f"你好， {user}")  # >>> 你好， Mr.Li
print(f"10 + 20 = {a1 + a2}")

# \r    回车，将 \r 后面的内容移到字符串开头，并逐一替换开头部分的字符，直至将 \r 后面的内容完全替换完成。

print("Hello 111\rWorld!") # >>> World!
print('google runoob taobao\r123456') # >>> 123456
print("Hello 执行进度条{:3}%".format(100))

# >>> Python2.6 开始，新增了一种格式化字符串的函数 str.format()，它增强了字符串格式化的功能。
# >>> 基本语法是通过 {} 和 : 来代替以前的 % 。

for i in range(101):
    print("\r{:1}%".format(i), end=" ")
    time.sleep(0.01)

print()

# string常用方法
print("++++++++++++++++++++++string常用方法++++++++++++++++++")
print("hello".capitalize())  # >>> Hello
print("hello".endswith("lo"))  # >>> True
print("hello".endswith("olo"))  # >>> false
print("hello".startswith("h")) # >>> True
print("Hello".lower()) # >>> hello
print("Hello".islower()) # >>> False
print("Hello".upper()) # >>> HELLO
print("hello".find("el")) # >>> 1
print("hello".index("el")) # >>> 1
print("hello".count("l")) # >>> 2
print("hello".replace("l", " ")) # >>> he  o
print("hello".split("l")) # >>>['he', '', 'o']
print("hello".split("ll")) # >>>['he', 'o']
print(" he llo ".strip()) # >>> he llo
print(len("hello")) # >>> 5
#print("hello".index("el0")) # >>> Traceback (most recent call last):
print(" ".join(["A","B","C","D","E","F"])) # >>> A B C D E F

#切片 语法[开始位置：结束位置：步长]
str = "abcdefghijk"
#        a   b  c  d  e  f  g  h  i  j   k
#        0   1  2  3  4  5  6  7  8  9  10
#      -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
print(str[0]) #a
print(str[2]) #c
print(str[0:5]) #abcde
print(str[:5])  #abcde
print(str[0:-1]) #abcdefghij
print(str[0:]) #abcdefghij
print(str[0:-4]) #abcdefg
print(str[0:5:-1]) #
print(str[0:5:1]) #abcde
print(str[-1:8:-1]) #kj


for i in range(1, 10):
    if i <= 5:
        if i  == 3:
            break
        print(i)
else:
    print("进入else")